package menus;

import java.io.Serializable;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import user.Rights;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;

/**
 *
 * @author Thorsten Ludwig
 */
@Entity
public class MenuCategory implements Serializable {
    
    /**
     * 
     */
    private String name;
    
    /**
     * 
     */
    @OneToMany
    private List<LectureMenuItem> menuItems;
    
    /**
     * 
     */
    @OneToOne(cascade=CascadeType.ALL)
    private Rights rights;
    @Id
    @GeneratedValue
    private Long id;

    public MenuCategory() {
    }
    
    /**
     * 
     * @param name 
     */
    public MenuCategory(String name) {
        this.name = name;
        this.menuItems = new ArrayList<LectureMenuItem>();
        this.rights = new Rights();
    }
    
    /**
     * 
     * @param item 
     */
    public void addItem(LectureMenuItem item) {
        System.out.println("Kategorie " + this.name + " bekam ein Item namens " + item.getName());
        this.menuItems.add(item);
    }

    public String getName() {
        return name;
    }

    public List<LectureMenuItem> getMenuItems() {
        return menuItems;
    }

    public Rights getRights() {
        return rights;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void removeItem(LectureMenuItem item) {
        this.menuItems.remove(item);
    }

    public void setMenuItems(List<LectureMenuItem> menuItems) {
        this.menuItems = menuItems;
    }
}